<template>
    <el-dialog
        class="dialog"
        :destroy-on-close="true"
        :title="title"
        :visible.sync="isShow"
        :close-on-click-modal="false"
        @close="onDialogClose"
    >
        <el-form
            ref="form"
            label-width="auto"
            class="form"
            :model="formData"
            :rules="rules"
        >
            <el-form-item label="配置项" prop="param_code">
                <el-select
                    v-model="formData.param_code"
                    placeholder="请选择配置项"
                >
                    <el-option
                        v-for="item in parkSetItemData"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    ></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="onDialogClose">取消</el-button>
            <el-button type="primary" @click="onSubmit">确认</el-button>
        </div>
    </el-dialog>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { Action, State } from 'vuex-class';
import { mixinDialogForm } from "@/mixin/dialog/Form";
@Component({
    mixins: [mixinDialogForm]
})
export default class parkParamAdd extends Vue {
    // 新增
    @Action("parkParkset/add") itemAdd: any;
    @State((state) => state.sharing.parkSetItem) parkSetItemData: any;

    selectItem!: any;
    addInit() {
        const me = this as any;
        me.formData.yard_sn = me.selectItem.yard_sn;
    }


    editInit(data: any) {
        const me = this as any;
        me.formData = Object.assign({}, me.formData, data);
    }

    // 表单数据
    formData: any = {
        param_code: "",
        yard_sn: ""
    };

    /**
     * 校验配置
     *
     * @type {*}
     * @memberof mixinViewRules
     */
    rules: any = {
        param_code: [
            {
                required: true,
                message: "请选择配置项",
                trigger: "blur"
            }
        ]
    };
    // 标题
    get title() {
        const title = (this as any).isEdit ? "编辑" : "新增";
        return `${title}配置`;
    }
}
</script>
